package timeslice
{
	import global.$optionDialog;
	import globals.$rootScene;
	
	import slices.TimeSlice;
	import globals.$root;
	import slices.FunctionSlice;
	
	public class PopOptionDialog extends TimeSlice
	{
		public var quest:String;
		public var choice:Array;
		
		public function PopOptionDialog(quest:String, choice:Array):void 
		{
			super();
			this.quest = quest;
			this.choice = choice;
		}
		
		override public function onStart():void {
			$optionDialog.setContent(quest, choice);
			$optionDialog.x = $root.stage.stageWidth/2;
			$optionDialog.y = $root.stage.stageHeight/3;
			$optionDialog.onSelect = onSelect; 
			$optionDialog.display($root);
		}
		
		private function onSelect(i:int):void {
			addOutput("result", i);
			$optionDialog.disappear().appendNext(new FunctionSlice(onDialogDisappear));
		}
		
		private function onDialogDisappear():void {
			isEnd = true;
		}
	}
}